package com.ming.transaction.config;

import com.ming.transaction.common.interceptor.jwtInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 拦截器释放白名单
 * @author: Chenming
 * @date 2023/5/3 23:31
 */

@Configuration
public class InterceptorConfig implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 拦截所有请求 ，通过判断 token 是否合法来决定是否登录
        registry.addInterceptor(jwtInterceptor())
                .addPathPatterns("/**")
                .excludePathPatterns("/user/loginRig","/kaptcha","/doc.html","/swagger-ui.html/**",
                        "/swagger-resources/**","/webjars/**","/user/load/**","/goods/load/**",
                        "/user/upload","/goods/upload","/dialy/exportExcel","/goods/list");
    }

    @Bean
    public jwtInterceptor jwtInterceptor() {
        return new jwtInterceptor();
    }
}
